//
//  HZ_more_TableViewCell.m
//  HZ_Beautiful_Music
//
//  Created by dllo on 16/4/6.
//  Copyright © 2016年 ui. All rights reserved.
//

#import "HZ_more_TableViewCell.h"
#import "UIImageView+WebCache.h"
@interface HZ_more_TableViewCell ()

@property (nonatomic, strong) UIImageView *image;
@property (nonatomic, strong) UIImageView *bookimage;
@property (nonatomic, strong) UILabel *namelabel;
@property (nonatomic, strong) UILabel *desclabel;
@property (nonatomic, strong) UILabel *clickCountlabel;
@property (nonatomic, strong) UIView *view;



@end
@implementation HZ_more_TableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
    
        
        self.backgroundColor = [UIColor whiteColor];
        
        self.image = [[UIImageView alloc] init];
        
//        self.image.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:self.image];
        
        self.bookimage = [[UIImageView alloc] init];
        self.bookimage.image = [UIImage imageNamed:@"iconfont-shu"];
//        self.bookimage.backgroundColor = [UIColor colorWithRed:0.393 green:0.393 blue:0.001 alpha:1.000];
        [self.contentView addSubview:self.bookimage];
        
        self.namelabel = [[UILabel alloc] init];
        
//        self.namelabel.backgroundColor = [UIColor colorWithRed:0.882 green:0.673 blue:1.000 alpha:1.000];
        
        _namelabel.font = [UIFont systemFontOfSize:20];
        [self.contentView addSubview:self.namelabel];
        self.desclabel = [[UILabel alloc] init];
        
//        self.desclabel.backgroundColor = [UIColor colorWithRed:0.882 green:0.673 blue:1.000 alpha:1.000];
        
        _desclabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.desclabel];
        
        self.clickCountlabel = [[UILabel alloc] init];
        
//        self.clickCountlabel.backgroundColor = [UIColor colorWithRed:0.882 green:0.673 blue:1.000 alpha:1.000];
        _clickCountlabel.textAlignment = 1;
        _clickCountlabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.clickCountlabel];
        
        self.view = [[UIView alloc] init];
        self.view.backgroundColor = [UIColor colorWithWhite:0.803 alpha:1.000];
        [self.contentView addSubview:self.view];
    }
  
    return self;
    
    
}


-(void)layoutSubviews{
    
    
    [super layoutSubviews];
    _image.frame = CGRectMake(20, 20, self.bounds.size.width - 40, self.bounds.size.height / 2);
    _namelabel.frame = CGRectMake(_image.frame.origin.x, self.bounds.size.height / 2 + 25, self.bounds.size.width / 2, 35);
    _desclabel.frame = CGRectMake(20, _namelabel.frame.origin.y + 40, self.bounds.size.width - 40 , 25);
    _bookimage.frame = CGRectMake(self.bounds.size.width - 80, _image.frame.origin.y + 10, 20, 20);
    _clickCountlabel.frame = CGRectMake(self.bookimage.frame.origin.x + 20, _bookimage.frame.origin.y, 30, 20);    
    _view.frame = CGRectMake(0, self.bounds.size.height - 1, self.bounds.size.width, 1);
}

-(void)setModel:(HZ_more_Model *)model{
    
    
    _model = model;
    
    [_image sd_setImageWithURL:[NSURL URLWithString:_model.picUrl]];
    
    _namelabel.text = _model.name;
    _desclabel.text = _model.desc;
    
    NSString *str = [NSString stringWithFormat:@"%ld", _model.clickCount];
    
    _clickCountlabel.text = str;
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
